using UnityEngine;

namespace EntityKit.Editor
{
    public class ExcelPathSettingConfig : ScriptableObject
    {
        /// <summary>
        /// Excel文件路径
        /// </summary>
        public string ExcelFilePath;

        /// <summary>
        /// 代码输出路径
        /// </summary>
        public string Excel2CodePath;

        /// <summary>
        /// Json输出路径
        /// </summary>
        public string Excel2JsonPath;

        private void OnEnable()
        {
            // 只有当路径为空时才设置默认值，避免覆盖用户设置
            if (string.IsNullOrEmpty(ExcelFilePath))
            {
                ExcelFilePath = Application.dataPath + @"/../Configs/Excel/"; 
            }
            
            if (string.IsNullOrEmpty(Excel2CodePath))
            {
                Excel2CodePath = Application.dataPath + @"/Scripts/Configs/ExcelCode/";
            }
            
            if (string.IsNullOrEmpty(Excel2JsonPath))
            {
                Excel2JsonPath = Application.dataPath + @"/AssetPacks/Configs/Json/";
            }
        }
        
        public static ExcelPathSettingConfig LoadOrCreateExcelPathSettingConfig()
        {
            var defaultPath = "Assets/Editor/Configs/ScriptableObject/ExcelPathSettingConfig.asset";
            return ScriptableObjectHelper.LoadOrCreateSingletonScriptableObject<ExcelPathSettingConfig>(defaultPath);
        }
    }
}